<?php

$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$params=array('uniacid'=>$_SESSION['uniacid']);
    $fields=array();
    $orderby='id desc';
	$total='';
	$return['list']=pdo_getslice('jy_offlineapi_goods_log',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($return['list'] as &$item){
			$goods=pdo_get('jy_offlineapi_goods',array('id'=>$item['goods_id']));
			$item=array_merge($goods,$item);
			$item['member']=cfc('core')->member_show($item['mid']);
			$orderstatus=pdo_getcolumn('jy_weishop_order_goods',array('orderid'=>$item['order_id'],'goodsid'=>$item['goods_id']),'status');
			if($orderstatus==3){
				pdo_update('jy_offlineapi_goods_log',array('status'=>1),array('id'=>$item['id']));	
			}
	}
	$htmls=array(
		'type'=>'list',		
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'title','title'=>'套餐名称','type'=>'string'),
			array('name'=>'member','title'=>'会员信息','type'=>'member'),
			//array('name'=>'type','title'=>'套餐类型','type'=>'radio','options'=>'types'),
			array('name'=>'status','title'=>'状态','type'=>'radio','options'=>'log_status'),
			array('name'=>'createtime','title'=>'创建时间','type'=>'string'),		
		)),
	);
	$return['htmls']=$htmls;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$return['types']=$this->types;
	$return['log_status']=$this->log_status;
	exi($return);
}
if($_RQ['op']=='del'){

	$id=intval($_RQ['id']);
	if($id){
		pdo_delete('jy_offlineapi_goods_log',array('id'=>$id));	
	}
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
		foreach($del as $id){
			$id=intval($id);
			if($id){
				pdo_delete('jy_offlineapi_goods_log',array('id'=>$id));
			}
		}
	}
	exi('删除成功！');
}	

?>